<template>
  <view :style="{ 'height': getStatusBarHeight, 'background-color': backgroud }" class="uni-status-bar">
    <slot></slot>
  </view>
</template>

<script>
import { getWindow } from '../../lib/function/index'

export default {
  name: 'StatusBar',
  props: {
    statusBarHeight: {
      type: String,
      default: ''
    },
    backgroud: {
      type: String,
      default: ''
    }
  },
  computed: {
    // 获取系统状态栏高度
    getStatusBarHeight() {
      if (this.statusBarHeight) {
        return this.statusBarHeight
      }
      const sysInfo = getWindow()
      return `${sysInfo.statusBarHeight}px`
    }
  }
}
</script>

<style lang="scss">
.uni-status-bar {
  position: relative;
  z-index: 3;
  // width: 750rpx;
  height: 20px;
  // height: var(--status-bar-height);
}
</style>
